import { BaseController, CoolController } from "@cool-midway/core";
import { Body, Get, Inject, Post, Query } from "@midwayjs/core";
import { MediaInfoService } from "../../service/info";
import { MediaInfoEntity } from "../../entity/info";
import { AddMediaDTO, ListByProviderIdDTO, ListMediaDTO } from "../../dto/info";
import { Context } from "@midwayjs/koa";

@CoolController({
  api: ['list', 'page', 'delete'],
  entity: MediaInfoEntity,
  service: MediaInfoService,
})
export class ProviderMediaController extends BaseController {
  @Inject()
  mediaInfoService: MediaInfoService;

  @Inject()
  ctx: Context;

  @Post('/addMy', { summary: '新增我的媒体资源' })
  async addMy(@Body() dto: AddMediaDTO) {
    return this.ok(await this.mediaInfoService.addByProviderId(dto, this.ctx.provider?.id!));
  }

  @Get('/listMy', { summary: '我的媒体资源列表' })
  async listMy(@Query() query: ListMediaDTO) {
    return this.ok(await this.mediaInfoService.listByProviderId(query, this.ctx.provider?.id!));
  }

  @Get('/listByProviderId', { summary: '按服务人员ID获取媒体资源列表' })
  async listByProviderId(@Query() query: ListByProviderIdDTO) {
    return this.ok(await this.mediaInfoService.listByProviderId({ type: query.type }, query.providerId));
  }

  @Get('/listByCurrentTeam', { summary: '当前团队媒体资源列表' })
  async listByCurrentTeam(@Query() query: ListMediaDTO) {
    return this.ok(await this.mediaInfoService.teamListByProviderId(query, this.ctx.provider?.id!));
  }


}


